<ui:composition template="../template/template.xhtml" xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
	<ui:define name="localizacao">
		<h:outputText value="&#160; Concursos" />
	</ui:define>
	<ui:define name="content">
		<p:ajaxStatus style="width:200px;height:200px;position:fixed;right:5px;bottom:5px">
			<f:facet name="start">
				<h:graphicImage value="../public/images/loading45.gif" />
			</f:facet>

			<f:facet name="complete">
				<h:outputText value="" />
			</f:facet>
		</p:ajaxStatus>

		<div class="arrow fright">
			<p:commandButton actionListener="#{scheduleController.listarConcursos()}"
				icon="ui-icon-calculator" title="Visualizar no calendario" value="Visualizar calendário" />
		</div>


		<h4>
			<b><h:outputText value="Meus Concursos: " /></b>
		</h4>
		<br />
		<h:form id="formAddReferencia">
			<p:commandButton id="lembrete" icon="ui-icon-plusthick" value="Adicionar Novo"
				styleClass="ui-priority-primary" actionListener="#{concursoMB.urlCadConcurso()}">
			</p:commandButton>
		</h:form>
		<br />
		<h:form>
			<p:panel>
				<table>
					<tr>
						<td><h:outputText value="Filtrar por: " /></td>
					</tr>
					<tr>
						<td><p:selectOneMenu id="filtro" value="#{concursoMB.filtroBusca}">
								<f:selectItem itemLabel="Todos" itemValue="Todos" />
								<f:selectItem itemLabel="Novos" itemValue="Novos" />
								<f:selectItem itemLabel="Antigos" itemValue="Antigos" />
								<p:ajax listener="#{concursoMB.buscar()}" />
							</p:selectOneMenu></td>
					</tr>
				</table>
			</p:panel>
		</h:form>

		<br />

		<h:form id="listaConcursos">
			<p:growl id="msg1" showDetail="true" sticky="false" life="5000" />
			<p:dataTable value="#{concursoMB.listaConcursos}" var="concurso" id="lista_concursos"
				emptyMessage="Nenhum concurso cadastrado" paginator="true" rows="10"
				paginatorTemplate="{PageLinks} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,15"
				draggableColumns="true" paginatorAlwaysVisible="false" paginatorPosition="bottom">
				<f:facet name="header">  
            		Concursos Cadastrados  
        		</f:facet>
				<p:column headerText="Nome" sortBy="#{concurso.nome}">
					<h:outputText value="#{concurso.nome}" />
				</p:column>
				<p:column headerText="Cargo" sortBy="#{concurso.cargo}">
					<h:outputText value="#{concurso.cargo}" />
				</p:column>
				<p:column sortBy="#{concurso.dataProva}" headerText="Data da Prova">
					<h:outputText value="#{concurso.dataProva}">
						<f:convertDateTime type="date" dateStyle="medium" />
					</h:outputText>
				</p:column>
				<p:column style="width:1%">
					<f:facet name="header">Ações</f:facet>
					<p:commandButton id="detalhes" action="#{concursoMB.exibirDetalhesConcurso(concurso)}"
						icon="ui-icon-search" title="Ver Detalhes" />
					<p:commandButton id="anexar_Arquivo_Link" action="#{concursoMB.anexarArquivo(concurso)}"
						icon="ui-icon-disk" title="Anexar Arquivo" />
					<p:commandButton id="excluir" icon="ui-icon-trash" title="Excluir"
						actionListener="#{concursoMB.selecionarConcurso(concurso)}" oncomplete="confirmation.show()"
						update=":formRemover, :listaConcursos:msg1" />
					<p:commandButton id="editar" icon="ui-icon-pencil" title="Editar"
						actionListener="#{concursoMB.updateConcurso(concurso)}" />
				</p:column>
			</p:dataTable>
		</h:form>


		<h:form id="formRemover">
			<p:confirmDialog id="confirmDialog"
				message="Excluir o concurso: #{concursoMB.concursoSelecionado.nome}" header="Certeza?"
				severity="alert" widgetVar="confirmation">
				<p:commandButton id="confirm" value="Sim" oncomplete="confirmation.hide()"
					action="#{concursoMB.excluirConcurso()}" />
				<p:commandButton id="decline" value="Nao" onclick="confirmation.hide()" type="button"
					styleClass="ui-priority-primary" />
			</p:confirmDialog>
		</h:form>

		<p:dialog id="modalDialog" header="Adicionar Lembrete" widgetVar="dlg2" modal="true" height="270">
			<h4>
				<h:outputText value="Concurso: #{lembreteMB.concursoSelecionado.nome}" />
			</h4>
			<br />
			<h:form id="form-modal">
				<table>
					<tr>
						<td><h:outputText value="Titulo: " /></td>
						<td><p:inputText id="titulo" value="#{lembreteMB.lembrete.titulo}" required="true"
								requiredMessage="Campo obrigatorio" /></td>
						<td><p:message for="titulo" /></td>
					</tr>
					<tr>
						<td><h:outputText value="Informacao: " /></td>
						<td><p:inputText id="informacao" value="#{lembreteMB.lembrete.informacao}"
								required="true" requiredMessage="Campo obrigatorio" /></td>
						<td><p:message for="informacao" /></td>
					</tr>
					<tr>
						<td><h:outputText value="Data do lembrete: " /></td>
						<td><p:calendar id="data_lembrete" locale="pt" showButtonPanel="true" required="true"
								navigator="true" requiredMessage="Campo obrigatorio" pattern="dd/MM/yyyy"
								yearRange="c-50:c-0" value="#{lembreteMB.lembrete.dataLembrar}" /></td>
						<td><p:message for="data_lembrete" /></td>
					</tr>
					<tr>
						<td><h:outputText value="Enviar E-mail: " /></td>
						<td><p:selectBooleanCheckbox value="#{lembreteMB.lembrete.enviarEmail}" /></td>
					</tr>
					<tr>
						<td><br /></td>
					</tr>
					<tr>
						<td><p:commandButton listener="#{form-modal}" value="Cadastrar"
								oncomplete="if (!args.validationFailed) $('#form-modal\\:link_cadLembrete').click()"
								update="form-modal" process="@form" styleClass="ui-priority-primary" /> <p:commandLink
								style="display:none" id="link_cadLembrete"
								actionListener="#{lembreteMB.cadastrarLembrete()}" update="form-modal,:listaConcursos:msg1"
								oncomplete="dlg2.hide()" /></td>
					</tr>
				</table>
			</h:form>
		</p:dialog>


	</ui:define>
</ui:composition>